package cn.com;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import news.*;
import dao.*;

public class ShowNew extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public ShowNew() {
		super();
	}

	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		this.doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		MysqlNew mn = new MysqlNew();
		List<NewTi> list1 = mn.GMshow(1, 5);
		request.setAttribute("list1", list1);
		List<NewTi> list2 = mn.GMshow(2, 5);
		request.setAttribute("list2", list2);
		List<NewTi> list3 = mn.GMshow(5, 5);
		request.setAttribute("list3", list3);
		MysqlLeiBie my = new MysqlLeiBie();
		ArrayList<LeiBie> list4 = my.showBei();
		request.setAttribute("list4", list4);

		int page2 = 1;
		try {
			page2 = Integer.parseInt(request.getParameter("pageNo"));
			if (page2 < 1) {
				page2 = 1;
			}
		} catch (Exception e) {
		}
		MysqlPage mp = new MysqlPage();
		Page p = mp.OnShow(page2);
		List<NewTi> list5 = mn.show(page2, 15);
		request.setAttribute("list5", list5);
		request.setAttribute("page", p);
		request.getRequestDispatcher("/newshow.jsp").forward(request, response);

	}

	public void init() throws ServletException {
		// Put your code here
	}

}
